<template>
  <div class="app-container pagebox ">
    <div class="bg">
     
      <div style="background-color:#fff;">
        <a-table  :pagination='false' :columns="columns" :data-source="data"  :rowKey="(record, index) => { return index;}"/>
      </div>
      <div style="padding: 20px">
                <a-pagination
                  size="small"
                  :total="total"
                  :show-total="(total) => `一共 ${total} 条`"
                 
                  :default-page-size="10"
                  @change="changepageSignIn"
                />
              </div>
    </div>
  </div>
</template>
<script>
//
import api from '@/api/equipment';
const columns = [
  {
    title: "程序名",
    dataIndex: "produceName"
  },
  {
    title: "加工机床",
    dataIndex: "macNumb"
  },
  {
    title: "加工开始时间",
    dataIndex: "startTime"
  }, {
    title: "加工结束时间",
    dataIndex: "endTime"
  }, {
    title: "加工时间",
    dataIndex: "produceTime"
  }, {
    title: "主轴运行时长",
    dataIndex: "spindleTime"
  }, {
    title: "主轴最大负载",
    dataIndex: "maxLoad"
  }, {
    title: "平均修调",
    dataIndex: "override"
  }, {
    title: "当前计件数",
    dataIndex: "partCount"
  }
];


export default {
  data() {
    return {
      data:[],
      columns,
      form: { num: 1 },
      options1: [],
      options2: [],
      CompanyId:null,
      equList:[],
      equID:null,
      equindex:0,
      MacSNsList:[],
      MacSNId:null,
      username:null,
      MacSNs:[],
      pageSize:10,
      pageNum:1,
      total:0,
    };
  },
  created() {
    if(this.$route.query.macsn){
     this.MacSNId=this.$route.query.macsn;
     this.equID=this.$route.query.groupid;
     
    }
    let roleId=localStorage.getItem('roleId')
    if(roleId==1){
      this.CompanyId = localStorage.getItem("compid");
    }else{
      this.CompanyId = localStorage.getItem("choseCompanyId");
    }
    this.username =this.userName=localStorage.getItem("userName")
     this.getAllProduce()
  },
  methods: {
    changepageSignIn(size){
this.pageNum=size;
this.getAllProduce()
    },
    macSNchange(id){
      this.pageNum=1
      this.MacSNId=id;
      this.getAllProduce()
    },
    changroup(index){
      this.equID=this.equList[index].groupid;
      this.MacSNs=this.equList[index].MacSNs;
      this.MacSNId=this.MacSNs[0].macsn;
      this.pageNum=1;
      this.getAllProduce()
    },
    getAllProduce(){
      let params={
        Username:this.username,
        companyId:this.CompanyId,
        groupId:this.equID,
        macSN:this.MacSNId,
        pageSize:this.pageSize,
        pageNum:this.pageNum
      }
      api.getAllProduce(params).then((res)=>{
        this.data=res.data.rows;
        this.total=res.data.total
      })
    },
    getEquGroup(){
      let params={
        Username:this.username,
        compid:this.CompanyId,
      }
      api.CompanyGroupList(params).then((res)=>{
        this.equList=res.Data;
        this.equID=this.equList.unshift({groupname:'全部',groupid:-2});
        this.equID=this.equList[0].groupid;
        if(this.equList[0].MacSNs){
 this.MacSNs=this.equList[0].MacSNs;
        this.MacSNId=this.MacSNs[0].macsn;
        }
       
        this.getAllProduce()
      })
    },
    handleSubmit() {

    }
  }
};
</script>
<style scoped lang="less">
@import "index.less";
</style>
